//
//  SourceList.h
//  Amber
//
//  Created by Keith Duncan on 04/05/2007.
//  Copyright 2007 thirty-three. All rights reserved.
//

#import <Cocoa/Cocoa.h>

#import "AmberKit/AFKeyValueBinding.h"

@class AFTextFieldCell, AFImageTextCell;

@protocol AFSourceListDelegateProtocol;
@protocol AFSourceListDataSourceProtocol;

/*!
	@const
 */
extern NSString *AFContentImagesBinding;

/*!
	@class
	@abstract    An iLife '08 style source view
	@discussion
	
	This is a bindings driven view that displays a hierarchy of data like an outline view
	
	Exposed Bindings:
 
	Required Bindings, these provide the content
 
	• <tt>NSContentBinding</tt>, the arrangedObjects object of an NSTreeController or another compatable controller
	• <tt>KDContentImagesBinding</tt>, the key path by which the images are retrieved
	• <tt>NSContentValuesBinding</tt>, the key path by which the item titles are retrieved
 
	Optional Bindings
	
	• <tt>KDSelectionIndexPathBinding</tt>, only a single index path is used, it's singular because a user shouldn't be able to select multiple row in a source view 
	• <tt>NSSelectedValueBinding</tt>, this is the selected item's title
 */
@interface AFSourceList : NSView <AFKeyValueBinding> {
	id <AFSourceListDelegateProtocol> _delegate;
	id <AFSourceListDataSourceProtocol> _dataSource;
	
	NSMutableDictionary *_bindingInfo;
	
	AFTextFieldCell *_titleCell;
	AFImageTextCell *_contentsCell;
	
	CGFloat _rowHeight, _nodeSeparation;
	
	NSMutableSet *_expanded, *_expandable, *_disclosureButtons;
	NSCountedSet *_disclosureLevels;
}

/*!
	@property
 */
@property (assign) IBOutlet id <AFSourceListDelegateProtocol> delegate;

/*!
	@property
 */
@property (assign) IBOutlet id <AFSourceListDataSourceProtocol> dataSource;

@end


/*!
	@protocol
 */
@protocol AFSourceListDelegateProtocol <NSObject>

 @optional

/*!
	@method
	@abstract	root children are NEVER selectable and you won't be queried
 */
- (BOOL)sourceList:(AFSourceList *)view canSelectObject:(id)node;

/*!
	@method
	@abstract	root children without leaves are expected to be removed, return YES here to override this
 */
- (BOOL)sourceList:(AFSourceList *)view shouldDisplayRootLeaf:(id)node;

@end


/*!
	@protocol
 */
@protocol AFSourceListDataSourceProtocol <NSObject>

 @optional

/*!
	@method
	@abstract	you will only be asked about objects with children, root children default to NO like the 10.5 Finder
 */
- (BOOL)sourceList:(AFSourceList *)view shouldDisplayDisclosureForItem:(id)object;

@end
